//
//  MainViewController.m
//  ShareNavigation
//
//  Created by 水木 傅 on 12-5-4.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "MainViewController.h"
#import "SignInViewController.h"
#import "LoginInViewController.h"
#import "LoginInNavigationController.h"
#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"
#import "SingletonUser.h"
#import "PersonalViewController.h"
#import "FriendTravelTableViewController.h"
#import "NearbyFriendTableView.h"

@implementation MainViewController
@synthesize NearbyFriendButton;

@synthesize IndividualCenter;

#pragma ---  辅助函数  ---

//---  尚未登入时候的跳转页面  ---
-(void) NotLoginIn
{
     //---  获取mainstoryboard视图。通过这个，获取不同视图控制器  ---
    UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    LoginInNavigationController *LoginIncontroller = [board instantiateViewControllerWithIdentifier:@"LoginInNavigation"];
    
   [self.navigationController presentModalViewController:LoginIncontroller animated:YES]; 
}

#pragma ---  页面加载的函数  ---
-(void)viewDidLoad
{
}

- (void)viewDidUnload {
    [self setIndividualCenter:nil];
    [self setNearbyFriendButton:nil];
    [super viewDidUnload];
}

//---  签到按钮点击事件  ---
- (IBAction)SignInButton:(id)sender {
    //这是已经登入了
    if([SingletonUser shareManager].HasLogin == TRUE)
    {
        UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        SignInViewController *controller = [board instantiateViewControllerWithIdentifier:@"SignIn"];
        [self.navigationController pushViewController:controller animated:YES];
    }
    //拥护尚未登入
    else
    {
        [self NotLoginIn];
    }
}

- (IBAction)ImagePick:(id)sender {
}

- (IBAction)TravelButton:(id)sender {
    //这是已经登入了
    if([SingletonUser shareManager].HasLogin == TRUE)
    {
        UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        SignInViewController *controller = [board instantiateViewControllerWithIdentifier:@"Travel"];
        [self.navigationController pushViewController:controller animated:YES];
    }
    //拥护尚未登入
    else
    {
        [self NotLoginIn];
    }

}

- (IBAction)PersonCenterButton:(id)sender {
    //这是已经登入了
    if([SingletonUser shareManager].HasLogin == TRUE)
    {
        UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        PersonalViewController *controller = [board instantiateViewControllerWithIdentifier:@"Personal"];
        [self.navigationController pushViewController:controller animated:YES];
    }
    //拥护尚未登入
    else
    {
        [self NotLoginIn];
    }

}

- (IBAction)FriendTravelButton:(id)sender {
    //这是已经登入了
    if([SingletonUser shareManager].HasLogin == TRUE)
    {
        UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        FriendTravelTableViewController *controller = [board instantiateViewControllerWithIdentifier:@"FriendTravel"];
        [self.navigationController pushViewController:controller animated:YES];
    }
    //拥护尚未登入
    else
    {
        [self NotLoginIn];
    }

}

- (IBAction)NearbyFriendPressButton:(id)sender {
    //这是已经登入了
    if([SingletonUser shareManager].HasLogin == TRUE)
    {
        UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        NearbyFriendTableView *controller = [board instantiateViewControllerWithIdentifier:@"NearbyFriend"];
        [self.navigationController pushViewController:controller animated:YES];
    }
    //拥护尚未登入
    else
    {
        [self NotLoginIn];
    }

}
@end














